package com.cpkso.buss.backend.trade.domain;

import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.cpkso.buss.backend.user.domain.User;
import com.runze.base.domain.BaseEntity;

/**
 * 订单
 * @author wrzhxy@qq.com
 * @date 2018年3月12日
 */
@Entity
@Table(name="tborder"
	, indexes={
			@Index(name="idx_tb_buyerid", columnList="buyer_order_id"), 
			@Index(name="idx_tb_sellerid", columnList = "seller_order_id")})
@Cache(usage= CacheConcurrencyStrategy.READ_WRITE)
public class TbOrder extends BaseEntity {
	// 买家订单号
	@Basic(optional=false)
//	@Column(name="buyer_order_id", length=50, unique=true)
	@Column(name="buyer_order_id", length=50)
	private String buyerOrderId;
	// 卖家订单号
	@Basic(optional=false)
	@Column(name="seller_order_id", length=50, unique=true)
	private String sellerOrderId;
	// 买家号下单时间
	@Basic(optional=false)
	@Column(name="buyer_time")
	@Temporal(TemporalType.TIMESTAMP)
	private Date buyerTime;
	// 卖家号下单时间
	@Basic(optional=false)
	@Column(name="seller_time")
	@Temporal(TemporalType.TIMESTAMP)
	private Date sellerTime;
	// 买家号价格
	@Basic(optional=false)
	@Column(name="buyer_price")
	private Double buyerPrice;
	// 卖家号价格
	@Basic(optional=false)
	@Column(name="seller_price")
	private Double sellerPrice;
	// 商品
	// 存储买家商品名
	private String items;
	// 备注
	@Column(name="tip")
	private String tip;
	// 用户
	@Basic(optional=false)
	@ManyToOne
	@JoinColumn(name="user_id", foreignKey=@ForeignKey(name="FK_tbOrder_user"))
	private User user;
	
	public TbOrder() {
	}
	public TbOrder(String buyerOrderId, String sellerOrderId, Date buyerTime, Date sellerTime, Double buyerPrice,
			Double sellerPrice, String items, String tip, User user) {
		this.buyerOrderId = buyerOrderId;
		this.sellerOrderId = sellerOrderId;
		this.buyerTime = buyerTime;
		this.sellerTime = sellerTime;
		this.buyerPrice = buyerPrice;
		this.sellerPrice = sellerPrice;
		this.items = items;
		this.tip = tip;
		this.user = user;
	}
	public String getBuyerOrderId() {
		return buyerOrderId;
	}
	public void setBuyerOrderId(String buyerOrderId) {
		this.buyerOrderId = buyerOrderId;
	}
	public String getSellerOrderId() {
		return sellerOrderId;
	}
	public void setSellerOrderId(String sellerOrderId) {
		this.sellerOrderId = sellerOrderId;
	}
	public Date getBuyerTime() {
		return buyerTime;
	}
	public void setBuyerTime(Date buyerTime) {
		this.buyerTime = buyerTime;
	}
	public Date getSellerTime() {
		return sellerTime;
	}
	public void setSellerTime(Date sellerTime) {
		this.sellerTime = sellerTime;
	}
	public Double getBuyerPrice() {
		return buyerPrice;
	}
	public void setBuyerPrice(Double buyerPrice) {
		this.buyerPrice = buyerPrice;
	}
	public Double getSellerPrice() {
		return sellerPrice;
	}
	public void setSellerPrice(Double sellerPrice) {
		this.sellerPrice = sellerPrice;
	}
	public String getItems() {
		return items;
	}
	public void setItems(String items) {
		this.items = items;
	}
	public String getTip() {
		return tip;
	}
	public void setTip(String tip) {
		this.tip = tip;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	@Override
	public String toString() {
		return "TbOrder [buyerOrderId=" + buyerOrderId + ", sellerOrderId=" + sellerOrderId + ", buyerTime=" + buyerTime
				+ ", sellerTime=" + sellerTime + ", buyerPrice=" + buyerPrice + ", sellerPrice=" + sellerPrice
				+ ", items=" + items + ", tip=" + tip + ", user=" + user + "]";
	}
	
}
